import { useSelector, useDispatch } from 'react-redux'

export function useMap() {
  //  获取redux 图片显隐的状态
  const map = useSelector((state) => state.map.map)
  const smallMap = useSelector((state) => state.map.smallMap)
  // 修改状态要派发事件
  let $dispatch = useDispatch()
  // 具体派发事件
  const setMap = (map) => {
    $dispatch({
      // type为 reducer/方法名
      type: 'map/setMap',
      map,
    })
  }
  const setSmallMap = (map) => {
    $dispatch({ type: 'map/setSmallMap', map })
  }

  return { map, smallMap, setMap, setSmallMap }
}
